<? 
	if(isset($_POST['btngo']))
	{
		require("required/dbconnect.php");
		$pageno=$_POST['pageno'];
		
		header("Location:os_products.php?page=$pageno");
	}
	
	$title="Shop";
	require("required/dbconnect.php");
	require("required/share_function.php");
	$_SESSION['pid']=-1;
	
	
	if(empty($_GET['pid']))
	{
		$pid_q="";
		
	}
	else
	{
		$pid=mysql_real_escape_string($_GET['pid']);
		$main_cat_id=$pid;
		$pid_q=" and cat_id='$pid'  ";
	}
	
	if(empty($_GET['page']))
	{
		$page="1";
	}
	else
	{
		$page=$_GET['page'];
	}
	
	$totalperpage=15;

	$from=($page-1)*$totalperpage;	
	$get_product=mysql_query("select * from os_products where status=1 $pid_q order by order_id asc,create_datetime desc limit $from,$totalperpage")or die(mysql_error());
	$get_total=mysql_query("select * from os_products where status=1 $pid_q")or die(mysql_error());
	
	
	if(empty($_GET['pid']))
	{
		$location="All Products";
	}
	else
	{
		$pid=mysql_real_escape_string($_GET['pid']);
		$get_cat=mysql_query("select * from os_category where id='$pid'")or die(mysql_error());
		
		if(mysql_num_rows($get_cat)>0)
		{
			$location=mysql_result($get_cat,0,"name_eng");
			
			$_SESSION['pid']=mysql_result($get_cat,0,"name_eng");	
			
		}else{
			$location="Unknown";
		}
		
		
	}
	
	
	$count=mysql_num_rows($get_total);
	

	require("required/header.php"); 

?>
	
				<table width="100%" cellpadding="5" cellspacing="0"  >
					
					<tr>
						
						
                                <Td class="page_location" colspan="2">Your Location : <a href="index.php">Home</a>  > 
                                <?= $location ?></Td>
                        
                     </tr>
                     <tr>
                     	<Td width="20%" valign="top">
                        	<? require("required/product_category.php"); ?>
                        	
                        </Td>
                        <td width="80%" valign="top">
							<table width="100%">
							<?	
								if($count==0)
								{
							?>
								<tr>
									<td align="center"> :: No Record Found :: </td>
								</tr>
							<?	
								}
								else
								{
							?>
							
                            <tr>
								<td width="100%" colspan="6" align="left">
                                	
									<?= getPaging($totalperpage,$count,$page,"os_products.php?param=ntg") ?>
								</td>
								
							</tr>
							<?	productAvatar($get_product); ?>
								
							<tr>
								<td width="100%" colspan="6" align="left">
									<?= getPaging($totalperpage,$count,$page,"os_products.php?param=ntg") ?>
								</td>
								
							</tr>
                            <? } ?>
							</table>
						</Td>
					</tr>		  
			  	</table>
			
<? require("required/footer.php"); ?>	